package util;

class Person implements Comparable<Person>{
	int age;
	double height;
	String name;
	
	public Person(int age, double height,String name) {
		super();
		this.age = age;
		this.height = height;
		this.name = name;
	}
	/**
	 * this大返回正，参数大返回负数，一边大返回0
	 */
	@Override
	public int compareTo(Person o) {
//		return this.age - o.age;
//		return this.height > o.height ? 1 : (this.height < o.height? -1 : 0);
		return this.name.compareTo(o.name);
	}
}
public class CompareDemo {
	public static void main(String[] args) {
		// 0x1232131
		Person p1 = new Person(20,1.76,"zs");
		// 0x1213128
		Person p2 = new Person(20,1.77,"wangwu");
		
		System.out.println(p1.compareTo(p2));
	}
}
